package sort.cmp;

/**
 * @Author kaho
 * @create 2020/11/26
 */
public class 选择排序 {


    public static int[] selectSort(int[] arr){
        for (int i = arr.length - 1; i>0; i--){
            int max = 0;
            for (int j = 1; j <= i; j++){
                if (arr[max]<arr[j]) {
                    max = j;
                }
            }
            int tmp = arr[i];
            arr[i] = arr[max];
            arr[max] = tmp;
        }
        return arr;
    }

    public static void main(String[] args) {
        int[] arr = new int[]{19,14,5,7,8,1};
        int[] ints = selectSort(arr);
    }
}
